import React, { Component } from 'react';
import qs from '../../../utils/querystring';
import dkmobileCall from '../../../utils/dkmobileCall';
import httpweb from '../../../utils/httpWeb'
import './index.scss';
const qsObj = qs.parse();
export default class Index extends Component{
  state = {
    options: {},
    callupList: ['短酷', '航母']
  }
  callup = (index)=>{
    let options = Object.assign({}, this.state.options);
    delete options.description
    try{
      if (index == 0) {
        dkmobileCall(options)
      } else {
        httpweb.nativeCall(options)
      }
    } catch(err){
      console.log(err)
    }
    
  }
  componentDidMount(){
    if (qsObj.query) {
      let options = JSON.parse(decodeURIComponent(qsObj.query)) 
      this.setState({options})
    }
  }

  render(){
    const { callupList, options } = this.state;
    return (
      <div className='app-index'>
        <div className="callup-list">
          <div className="inner">
            <p>{options.description}</p>
            <div className="main">
              {
                callupList.map((item, index)=>(
                  <nav key={index} onClick={()=>{this.callup(index)}}>{item}拉起</nav>
                ))
              }
            </div>
            
          </div>
        </div>
      </div>
    )
  }
}